﻿using UnityEngine;
using System.Collections;

public class MovePath_1 : MovePath {
	
	// Use this for initialization
	void Start () {
		pathIndex = 0;
		pathLength = 4;

		moveSpeed = new Vector3[pathLength];
		movePath = new Vector3[pathLength];

		moveSpeed [0].Set (0.0f,0.1f,0.0f);
		movePath [0].Set (0.0f,-1.0f,0.0f);
	}
	
	// Update is called once per frame
	void Update () {
		//update position
		updatePosition ();
	}

	void updatePosition(){
		Camera mainCamera = Camera.main;

		float cameraWidth = 2 * mainCamera.aspect * mainCamera.orthographicSize; 
		float cameraHeight = 2 * mainCamera.orthographicSize;

		float xDistance = movePath [pathIndex].x * cameraWidth;
		float yDistance = movePath [pathIndex].y * cameraHeight;

		float xMoveOffset = xDistance * Time.deltaTime * moveSpeed[pathIndex].x;
		float yMoveOffset = yDistance * Time.deltaTime * moveSpeed[pathIndex].y;

		transform.position = new Vector3(transform.position.x + xMoveOffset,transform.position.y + yMoveOffset,0);
		
	}
}










